﻿$(function () {
    changeCode();
});

function changeCode() {
    $('.captcha').focus();
    var imgNode = document.getElementById("vimg");
    imgNode.src = "/include/checkcode?t=" + (new Date()).valueOf();      // 这里加个时间的参数是为了防止浏览器缓存的问题
}

$("#loginForm").submit(function () {
    $(this).ajaxSubmit({
        dataType: "json",
        beforeSubmit: function () {
            layer.load();
            return true;
        },
        success: function (res, status) {
            switch (res.code) {
                case "N200":
                    layer.closeAll('loading');
                    window.location.href = res.returnurl;
                    break;
                default:
                    layer.closeAll('loading');
                    $("#message-box").text(res.msg);
                    break;
            }
        }
    });
    return false;
});